﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EntityBinder.Binder
{
	public class ListContentBinder : ContentBinder
	{
		public override Interface.BinderType BinderType
		{
			get
			{
				return Interface.BinderType.ARRAY_OF_VALUE;
			}
		}

		public ListContentBinder(Interface.ITransformer _transformer) : base(_transformer)
		{

		}

		public override object Read(object _source, string _content, Interface.IMemberAccess _memberAccess)
		{
			object transformerData = Transformer.Read(_content);
			if (_memberAccess != null)
			{
				Internal.CollectionHelper.AddToList(_memberAccess, _source, transformerData);
			}
			return transformerData;
		}

		public override string Write(object _source, Interface.IMemberAccess _memberAccess)
		{
			return Transformer.Write(_source);
		}
	}
}
